/*
 * Copyright (c) 2020. bmy
 * Email：2271608011@qq.com
 * Github：https://github.com/helpcode
 */
import { Autowired } from "@ann/ioc.annotation";
import { UserService, ResponseType } from "@service/user.service";
import { BaseLogic } from "@logic/base.logic";
import { Methods, VueCustomize } from "@logic/base.type";

export class HomeLogic<T extends VueCustomize> extends BaseLogic implements Methods {

  @Autowired()
  public readonly UserService!: UserService;

  public title: string = "12222";
  
  public List: ResponseType[] = [];

  // constructor() {
  //   super();
  // }

  constructor(_: T) {
    super();
    console.log("constructor params: ", _);
    this._ = _
  }

  /**
   * 在这里面调用需要打开页面就执行的ajax请求
   * @constructor
   */
  public async StartUp (): Promise<void> {
    await this.getData();
  }

  /**
   * 请求首页数据
   */
  public async getData (): Promise<void> {
    this.List = await this.UserService.UserList({ type: 1, page: 1 });
    console.log("this.List: ", this.List);

    // let res = await this.UserService.login({ type: 2, page: 2 });
    // console.log("this.res: ", res);
    
    // 
    // await this._.$router.push('/About')
  }
}
